package com.atguig.f_methodreference.test;

import java.util.Arrays;
import java.util.Date;

public class Demo {
    public static void main(String[] args) {
        //使用InterA
        InterA ia = System.out::println;

        ia.show("张三");

        System.out.println("---------------------------");
        //使用InterB
        InterB ib = Integer::parseInt;

        Integer num = ib.change("500");
        System.out.println("num = " + num);
        System.out.println("---------------------------");
        //使用InterC
        InterC ic = Date::new;
        Date date = ic.get();
        System.out.println("date = " + date);
        System.out.println("---------------------------");
        //使用InterD
        InterD id = int[]::new;

        int[] arr = id.get(10);
        System.out.println("Arrays.toString(arr) = " + Arrays.toString(arr));

    }
}

//4个函数式接口
@FunctionalInterface
interface InterA{
    public abstract void show(String name);
}

@FunctionalInterface
interface InterB{
    public abstract Integer change(String num);
}

@FunctionalInterface
interface InterC{
    public abstract Date get();
}

@FunctionalInterface
interface InterD{
    public abstract int[] get(int length);
}